d = 20; % dimension of permutations
p = 0.5;   % observation probability
q = 0.8; % probability of not being corrupted by (multiplicative) outlier noise, q=1 means no outlier noise
delta = 1;    % noise level in additive noise, delta=0 means no additive noise

Number_of_n = 21;   % number of points
Array_n = 95 + 5 * (1:Number_of_n)';   % number of permutations 


Number_of_Sim = 30;   % number of repeats

% 
figure;
set(gcf,'units','points','position',[10,10,800,400])
% title('d=5, observe p_1 = 0.1, noise p_2=0.7')

subplot(1,2,1);
set(gca,'fontsize',15)
plot(Array_n, 1 - sum(err_Spectral)/Number_of_Sim,'-kp','LineWidth',2,'MarkerSize',10);
hold on
plot(Array_n, 1 - sum(err_GPM)/Number_of_Sim,'-ro','LineWidth',2,'MarkerSize',10);
plot(Array_n, 1 - sum(err_QR)/Number_of_Sim,'-g*','LineWidth',2,'MarkerSize',10);
hold off
legend('Spectral', 'GPM', 'QR','Location','northwest','FontSize',15)
xlabel('\textbf{$n$}','Interpreter','latex','FontSize',20)
ylabel('\textbf{Recovery Rate}','Interpreter','latex','FontSize',18)


subplot(1,2,2);
set(gca,'fontsize',15)
plot(Array_n,sum(time_Spectral)/(Number_of_Sim),'-kp','LineWidth',2,'MarkerSize',10);
hold on
plot(Array_n,sum(time_GPM)/(Number_of_Sim),'-ro','LineWidth',2,'MarkerSize',10);
plot(Array_n,sum(time_QR)/(Number_of_Sim),'-g*','LineWidth',2,'MarkerSize',10);
hold off
legend('Spectral', 'GPM','QR','Location','northwest','FontSize',15)
xlabel('\textbf{$n$}','Interpreter','latex','FontSize',20)
ylabel('\textbf{Time (s)}','Interpreter','latex','FontSize',18)

set(gcf,'Units','Inches');
pos = get(gcf,'Position');
set(gcf,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[pos(3), pos(4)])

% sgtitle(['$d$ = ', num2str(d), ', $p$ = ', num2str(p), ', $q$ = ', num2str(q), ', $\delta$ = ', num2str(delta)],'Interpreter','latex');

% Save
fig_name = ['n=', num2str(Array_n(1)),'-',num2str(Array_n(Number_of_n)), '_d=', num2str(d), '_p=', num2str(p), '_q=', num2str(q), '_delta=', num2str(delta)];
% mkdir('C:\Users\AMA\Dropbox\Academics and Research\Research Projects\Working\Synchronization over Orthogonal Group\experiment2020\Permutation\Results',folder_name);
% save(['Results\',num2str(folder_name),'\err_Spec.mat'], 'err_Spectral');
% save(['Results\',num2str(folder_name),'\err_LUD.mat'], 'err_QR');
% save(['Results\',num2str(folder_name),'\err_GPM.mat'], 'err_GPM');
% save(['Results\',num2str(folder_name),'\time_Spec.mat'], 'time_Spectral');
% save(['Results\',num2str(folder_name),'\time_LUD.mat'], 'time_QR');
% save(['Results\',num2str(folder_name),'\time_GPM.mat'], 'time_GPM');

fig_name = strrep(fig_name, '.', '');
savefig(['C:\Users\AMA\Dropbox\Academics and Research\Research Projects\Working\Synchronization over Orthogonal Group\Journal Paper\figures\',num2str(fig_name),'.fig']);